<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title> - 历史邮件</title>
	    <meta name="keywords" content="">
	    <meta name="description" content="">
	    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	    <link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	    <link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
	    <link href="__STATIC__/css/animate.css" rel="stylesheet">
	    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
	    <link href="__STATIC__/css/new_file.css" rel="stylesheet">
	</head>
	<body class="gray-bg">
		<div class="wrapper wrapper-content  animated fadeInRight">
			<div class="row">
				<div class="col-sm-12">
					<div class="ibox ">
						<div class="ibox-title">
							<h5>历史邮件</h5>
						</div>
						<div class="toogl_body">
	                    	<a href="Mail.html"><button type="button" class="btn btn-w-m btn-bt btn-white">新建邮件</button></a>
	                    	<a href="Mail_1.html"><button type="button" class="btn btn-w-m btn-info btn-bt">历史记录</button></a>
							<a href="Mail_2.html"><button type="button" class="btn btn-w-m btn-white btn-bt">操作记录</button></a>
							<div class="ibox-content ibox-jqGrid">
								<div class="form-group mmp-gbl"><br/>
									<label class="col-sm-2 control-dy">查询时间：</label>
									<div class="col-sm-8 form-time1">
										<input id="time1" class="form-control form-con-ban layer-date">
										<!--  <input type="text" placeholder="请输入查询时间段" class="form-control form-time-bk" id="time1" readonly="readonly">
                                         <span class="help-block m-b-none">请输入查询时间段</span> -->
									</div>
									<label class="col-sm-2 control-dy">UID：</label>
									<div class="col-sm-8 form-time1">
										<input id ="uid" class="form-control form-con-ban ">
										<!--  <input type="text" placeholder="请输入查询时间段" class="form-control form-time-bk" id="time1" readonly="readonly">
                                         <span class="help-block m-b-none">请输入查询时间段</span> -->
									</div>
									<button type="button" id="buttonid" class="btn btn-w-m btn-info">查询</button>
								</div>
		                        <div class="jqGrid_wrapper">
		                            <table id="table_list_1"></table>
		                            <div id="pager_list_1"></div>
		                        </div>
		                    </div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 游戏公告 修改  -->
		<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div id="gray_Nr">
				<div class="col-sm-6">
					<div class="ibox float-e-margins float-e-margins-2">
						<div class="ibox-title">
							<h5>详情</h5>
							<div class="ibox-tools" data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<div class="panel-body">
							<div class="ibox float-e-margins float-e-border">
								<div class="ibox-content">
									<form class="form-horizontal"><br/>
			                            <div class="form-group">
			                                <label class="col-sm-3 control-label">日期：</label>
			                                <div class="col-sm-8">
			                                	<input type="hidden" value="" class="form-control" readonly="" id="id"> 
			                                    <input type="text" value="" class="form-control" readonly="" id="date">  
			                                </div>
			                            </div>
			                            <div class="form-group">
			                                <label class="col-sm-3 control-label">邮件主题：</label>
			                                <div class="col-sm-8">
			                                    <input type="text" value="" class="form-control" readonly="" id="title">
			                                </div>
			                            </div>
			                            <div class="form-group">
			                                <label class="col-sm-3 control-label">附件：</label>
			                                <div class="col-sm-8">
			                                    <input type="text" value="" class="form-control" readonly="" id="goods"> 
			                                </div>
			                            </div>
			                            <div class="form-group">
			                                <label class="col-sm-3 control-label">邮件内容：</label>
			                                <div class="col-sm-8">
			                                    <input type="text" value="" class="form-control" readonly="" id="content">  
			                                </div>
			                            </div>
			                            <div class="form-group">
			                                <label class="col-sm-3 control-label">收件人信息：</label>
			                                <div class="col-sm-8">
			                                    <input type="text" value="" class="form-control" readonly="" id="recipient">   
			                                </div>
			                            </div>
			                        </form>
								</div>
							</div>
						</div>
						<!-- <div class="ibox-butz">
							<input class="btn btn-w-m btn-info" type="button" value="确定">
							<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消">
						</div> -->
					</div>
				</div>
			</div>
		</div>
		<!--游戏公告 修改end-->

<!--手机导航-->
<div class="to-fdh" style="display: none;">
	<img class="to-imgd" src="__STATIC__/img/phonedh.jpg">
	<div class="mob-nrlb">
		<ul>
			<li>
				<a class="mob-nrdh">管理</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('Player/gameplayer')}">玩家管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('system/notice')}">公告管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('email/mail')}">邮件管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Club/club')}">亲友圈管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Money/money')}">提现管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Order/order')}">订单管理</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh">数据</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('data/datagk')}">概況</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datawf')}">玩法</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datalc')}">留存</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datass')}">实时数据</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataczfx')}">充值分析</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataclub')}">亲友圈统计</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/president')}">高级会长</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/regionaldata')}">地区数据</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh mob-qbh">权限</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_list')}">权限管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_group')}">用户组管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('account/account_details')}">后台账号管理</a>
					</li>
				</ul>
			</li>
		</ul>
	</div>
</div>
<div id="zkbg">
	<img src="__STATIC__/img/dp.gif">
</div>
<div class="vnl-zz" style="display:none">
	<div><img src="__STATIC__/img/bqhp.gif"></div>
</div>
<!--手机适配-->
	    <script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
	    <script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
	    <script src="__STATIC__/js/plugins/peity/jquery.peity.min.js"></script>
	    <script src="__STATIC__/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
	    <script src="__STATIC__/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
	    <script src="__STATIC__/js/content.js?v=1.0.0"></script>
    	<script src="__STATIC__/js/plugins/laydate/laydate.js"></script>
		<script>   //手机适配
        $(function(){
            if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
                $("head").append("<link>");
                var css = $("head").children(":last");
                css.attr({
                    rel:  "stylesheet",
                    type: "text/css",
                    href: "__STATIC__/css/phone_sp.css"
                });
                var mql = window.matchMedia("(orientation: portrait)");
                if(mql.matches) { //竖屏样式
                    $(".vnl-zz").show();
                    $(".to-fdh").hide();
                }else{
                    $(".to-fdh").show();
                    $("html").width("100%");
                    $("body").width("100%");
                }
                mql.addListener(function(m) {
                    if(m.matches) {
                        // 改变到直立方向
                        $(".vnl-zz").show();
                        $(".to-fdh").hide();
                    }
                    else {
                        $(".to-fdh").show();
                        $(".vnl-zz").hide();
                        $("html").width("100%");
                        $("body").width("100%");
                    }
                });
            }
        });
        //导航显示展开
        $(".mob-nrdh").click(function(){
            $(this).next().toggle(".mob-nryc");
        });
        $(".to-imgd").click(function(){
            $(this).next().toggle(".mob-nrlb");
        });
        //手机适配end
			var i = 0;
			var mydata = [];

			$(function() {
				var dateArray = [];
				var myDate = new Date(); //获取今天日期
				myDate.setDate(myDate.getDate() - 7);
				var dateTemp;
				var flag = 1;
				for(var i = 0; i < 7; i++) {
					var Month = (myDate.getMonth() + 1) < 10 ? "0" + (myDate.getMonth() + 1) : (myDate.getMonth() + 1);
					//					console.log(Month);
					var mydate = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
					//					console.log(mydate);
					dateTemp = myDate.getFullYear() + "-" + Month + "-" + mydate;
					dateArray.push(dateTemp);
					myDate.setDate(myDate.getDate() + flag);
				};
				// $("#time1").val(dateArray[0]);
				// $("#time2").val(dateArray[6]);
				// _inquireClick()
			})
		$('#buttonid').on('click', function() {     //页面上的button按钮的click事件，重新获取参数后发送参数，然后重新加载数据。
		        // var start_time = $("#time1").val();
              	// var end_time = $("#time2").val();
            	var time = $("#time1").val();
             	var uid = $("#uid").val();
        		if(time !=""){
                	var start_time = time.substring(0,10)+" "+"00:00:00";
					var end_time = time.substring(13)+" "+"23:59:59";
                }else{
                	var start_time = "";
					var end_time = "";
                }
				
                $("#table_list_1").jqGrid('setGridParam',{
                	url:'__URL__/email_list_search',
                    datatype:'json',
                    postData:{'start_time':start_time,'end_time':end_time,'uid':uid}, //发送数据
                    page:1
                }).trigger("reloadGrid"); //重新载入
        });

        function _getMessage(t) {
				var id = $(t).parent().parent().children().eq(1).html();
				var date = $(t).parent().parent().children().eq(2).html();
				var title = $(t).parent().parent().children().eq(3).html();
				var goods = $(t).parent().parent().children().eq(4).html();
				var content = $(t).parent().parent().children().eq(5).html();
				var recipient = $(t).parent().parent().children().eq(6).html();
				$('#id').val(id);
				$('#date').val(date);
				$('#title').val(title);
				$('#goods').val(goods);
				$('#content').val(content);
				$('#recipient').val(recipient);

		}
		//撤销邮件
		function email_undo(t){
			var send_no= $(t).parent().parent().children().eq(1).html();
            var title= $(t).parent().parent().children().eq(3).html();
            var goods= $(t).parent().parent().children().eq(4).html();
            var content= $(t).parent().parent().children().eq(5).html();
            var recipient= $(t).parent().parent().children().eq(6).html();
            var sender= $(t).parent().parent().children().eq(7).html();
						
			    $.ajax({
					type: "post",
					url: "__URL__/email_sys_undo",
					data: {
						'send_no':send_no,
                        'title':title,
                        'goods':goods,
                        'content':content,
                        'recipient':recipient,
						'sender':sender,

					},
					dataType: "json",
					success: function(e) {
						// console.log(e);
						var json = eval("("+e+")");
						alert(json.msg);
						location.reload();
					},
					error: function(e) {
						// console.log(e);
                        var json = eval("("+e+")");
						alert(json.msg);
					}
				});
		}
        $(document).ready(function () {
        	var start_time = $("#time1").val();
            var end_time = $("#time2").val();
            $.jgrid.defaults.styleUI = 'Bootstrap';
            // Examle data for jqGrid
            $("#table_list_1").jqGrid({
                url:'__URL__/email_list_search',
                postData:{'start_time':start_time,'end_time':end_time},
                datatype: "json",
                mtype: 'POST',
                height: 450,
                autowidth: true,
                shrinkToFit: true,
                rowNum: 50,
                rowList: [50,100],
                colNames: ['id','批次号','日期', '邮件主题', '附件', '邮件内容','收件人','发件人', '操作'],
                colModel: [
                	{
                        name: 'id',
                        index: 'id',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center',
                        hidden :true,
                    },
                    {
                        name: 'send_no',
                        index: 'send_no',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center',
                        hidden :true,
                    },
                    {
                        name: 'send_time',
                        index: 'send_time',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'title',
                        index: 'title',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'goods',
                        index: 'goods',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'content',
                        index: 'content',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'recipient',
                        index: 'recipient',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center',
                        hidden :true,
                    },
                	{
                        name: 'sender',
                        index: 'sender',
                        width: 60,
                        formatter: function(sender) {
                            switch(Number(sender)){
                                case 0:
                                    return '系统';
                            }

                        },
                        align:'center'
                    },
                    {
						name: 'read_status',
						index: 'read_status',
						width: 60,
						formatter: function(read_status) {
							switch(Number(read_status)){
									case 0:
										return '<input type="button" value="详情" class="btn btn-info" data-toggle="modal" data-target="#myModal" onclick="_getMessage(this)"/><input type="button" value="撤销" id="fj" class="btn btn-danger" onclick="email_undo(this)"/>';
									case 1:
										return '<input type="button" value="详情" class="btn btn-info" data-toggle="modal" data-target="#myModal" onclick="_getMessage(this)"/>';
							}
							
						},
                        align:'center'
					}
                ],
                pager: "#pager_list_1",
                viewrecords: true,
                loadonce: true,
                caption: "",
                hidegrid: false
            });
            $(function(){
            	$("#fj").click(function(){
            		$("#fj").hide();
            		alert("撤销成功");
            	});
            });
			setTimeout(function(){
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
			},500);
            
		    laydate.render({
		      elem: '#time1'
		       //,type: 'datetime'
		       ,range: true
		    });
		    laydate.render({
		      elem: '#time2'
		      // ,type: 'datetime'
		      // ,range: true
		    });
        });
    </script>


	</body>

</html>